#include <pspctrl.h>
#include "Key.h"
int KeyPressed = 0;
int KeyHold = 0;
int KeyRelease = 0;
void UpdateKey()
{
	int currentkeystate = 0;
	SceCtrlData pad_data;
	sceCtrlReadBufferPositive(&pad_data, 1);
	currentkeystate = pad_data.Buttons;
	KeyRelease = 0;
	KeyRelease |= KeyPressed &~ currentkeystate;
	KeyRelease |= KeyHold &~ currentkeystate;
	KeyHold &= ~KeyRelease;
	KeyHold |= KeyPressed & currentkeystate;
	KeyPressed = ~(KeyPressed | KeyHold) & currentkeystate;	
}

int IsPressed(int key)
{
	return KeyPressed & key;
}

int IsReleased(int key)
{
	return KeyRelease & key;
}


int IsHold(int key)
{
	return KeyHold & key;
}

